RH adapter: races start on Grid's go (effective-format zeroing) + stage retry + stale-replay gate#372
Merged
Merged
Conversation
…etry, stale-replay gate
The field report ('first lap reads 7s but arrived 25s into the race') unwound
into three RH-adapter defects, diagnosed by probing the console's actual
websocket path against a live rig:
- prepare_instant_start zeroed the staging delays of the format that was
current AT STAGE TIME — but seating the heat switches RH's effective format
to the heat's CLASS format (RHRace's class_format_id override), so the race
staged with STOCK multi-second staging tones + delays on top of Grid's own
start procedure. Every race began ~5-7s after Grid's go (a DB-bloated RH
stretched it past 15s); lap stamps stayed race-relative so results were
self-consistent and the skew was invisible everywhere except live: laps,
tones, and callouts all arrived that late. The prepare now re-runs right
before stage_race, when the effective format is current and RH is READY.
Measured on the rig: the websocket-path lap latency fell from a constant
~7.1s to 0.28-0.37s (median 0.32s).
- A busy RH ('Attempted to stage race while status is not ready') silently
DROPS a stage — the race never starts and no passes record. The driver now
re-emits stage_race every 5s inside the settle window until RH confirms
RACING (paced above RH's stock staging so a retry can never restart a
countdown in progress).
- Lap records drained BEFORE this arming's RACING confirmation are a stale
replay — a busy RH re-broadcasts the PREVIOUS race's current_laps snapshot,
and remapping it contaminated the fresh heat with the last race's laps
(observed live: a new heat opening on lap 6+). ArmedHeat now carries a
started flag (set on SessionStarted, shared across reconnects so mid-race
snapshot replays still dedup) and pre-start passes are dropped.
Operational note: a long-lived test rig accumulates RH heats (one per race,
'Heat 166' by tonight) and slows staging/saves — reset the container's DB
periodically; the retry + gate make the failure mode safe rather than corrupt.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root-caused the 'lap reads 7s, arrives 25s' report. RH races the seated heat's class format — not the format
prepare_instant_starthad zeroed — so stock RH staging (~5s, worse on a bloated DB) ran on top of Grid's go, skewing every live surface while results stayed self-consistent. The prepare now re-runs immediately beforestage_race(effective format current, RH READY). Plus: a 5s stage retry for busy-RH dropped stages, and a per-arming RACING gate that drops pre-start lap records (a busy RH replays the previous race's snapshot — this contaminated a fresh heat with the old race's laps, observed live).Measured on the rig (websocket path, the console's actual data path): lap visibility latency fell from a constant ~7.1s to 0.28–0.37s (median 0.32s).
Workspace tests +
--features livebuild + lint clean.🤖 Generated with Claude Code